//package org.springframework.boot.alpacastudydemo;
//
//import net.jacobpeterson.alpaca.AlpacaAPI;
//import net.jacobpeterson.alpaca.model.util.apitype.BrokerAPIEndpointType;
//import net.jacobpeterson.alpaca.openapi.broker.model.Account;
//import net.jacobpeterson.alpaca.openapi.broker.model.AccountExtended;
//import org.springframework.boot.CommandLineRunner;
//import org.springframework.boot.SpringApplication;
//import org.springframework.boot.autoconfigure.SpringBootApplication;
//
//import javax.net.ssl.*;
//import java.security.SecureRandom;
//import java.security.cert.CertificateException;
//import java.security.cert.X509Certificate;
//import java.util.UUID;
//
//@SpringBootApplication
//public class AlpacaExample implements CommandLineRunner {
//
//    // 替换为你的 Alpaca API Key ID
//    private static final String brokerAPIKey = "CK6CPWGZZBWOIDLGJP3H";
//    // 替换为你的 Alpaca Secret Key
//    private static final String brokerAPISecret = "awNuqpDdRcBc1U6n4Z7MP7HpsOeIKVZtTMJMbyJf";
//
//    public static void main(String[] args) {
//        SpringApplication.run(AlpacaExample.class, args);
//    }
//
//    @Override
//    public void run(String... args) throws Exception {
//        try {
//            // 忽略 SSL 证书和主机名验证（仅用于测试）
//            TrustManager[] trustAllCerts = new TrustManager[]{
//                    new X509TrustManager() {
//                        public X509Certificate[] getAcceptedIssuers() { return null; }
//                        public void checkClientTrusted(X509Certificate[] certs, String authType) {}
//                        public void checkServerTrusted(X509Certificate[] certs, String authType) {}
//                    }
//            };
//
//            SSLContext sc = SSLContext.getInstance("SSL");
//            sc.init(null, trustAllCerts, new java.security.SecureRandom());
//            HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
//
//            // 忽略主机名验证
//            HostnameVerifier allHostsValid = (hostname, session) -> true;
//            HttpsURLConnection.setDefaultHostnameVerifier(allHostsValid);
//
//            // 创建 Alpaca API 实例
//            AlpacaAPI alpacaAPI = new AlpacaAPI(brokerAPIKey, brokerAPISecret,BrokerAPIEndpointType.SANDBOX );
////            UUID accountId = UUID.fromString("5a7e8f9c-d3b4-4d1a-8e2f-3c4b5a6d7e8f");
//            alpacaAPI
//
//            System.out.println("=== Alpaca Account Info ===");
//            System.out.println("Account ID: " + account.getId());
//            System.out.println("Status: " + account.getStatus());
//
//        } catch (Exception e) {
//            System.err.println("Error calling Alpaca API:");
//            e.printStackTrace();
//        }
//    }
//}
